<template>
  <PageWrapper dense contentFullHeight fixedHeight>
    <BasicTable @register="registerTable">
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'action'">
          <TableAction :actions="[
            {
              label: '查看详情',
              onClick: handleDetail.bind(null, record),
            },
          ]" />
        </template>
      </template>
    </BasicTable>
    <ModalDetail @register="registerModal" />
  </PageWrapper>
</template>
<script setup lang="ts">
import { PageWrapper } from '@/components/Page'
import { BasicTable, useTable, TableAction } from '@/components/Table'

import { searchFormSchema, columns } from './data'
import { getRecordsList } from '@/api/sys/operationRecords'
import ModalDetail from './ModalDetail.vue'
import { useModal } from '@/components/Modal'

defineOptions({ name: 'OperationRecords' })

const [registerModal, { openModal }] = useModal()

const [registerTable] = useTable({
  title: '操作记录',
  rowKey: 'id',
  api: getRecordsList,
  size: 'small',
  columns,
  useSearchForm: true,
  formConfig: {
    labelWidth: 80,
    schemas: searchFormSchema,
    autoSubmitOnEnter: true,
  },
  bordered: true,
  actionColumn: {
    width: 120,
    title: '操作',
    dataIndex: 'action',
  },
})

const handleDetail = (record) => {
  openModal(true, {
    isUpdate: false,
    id: record.id,
  })
}
</script>
